package router

import (
	"api-gateway/basic/config"
	"api-gateway/handle"
	"api-gateway/middle"

	"github.com/gin-gonic/gin"
	"github.com/share309/gojwt"
)

func Router() *gin.Engine {
	r := gin.Default()
	r.Use(middle.Cors())
	user := r.Group("/user")
	{
		user.POST("login", handle.Login)
	}
	discount := r.Group("/discount")
	{
		discount.GET("/list", handle.DiscountList)
		discount.Use(gojwt.JWTAuth(config.TOKEN_Key))
		discount.POST("/created", handle.CreatedDiscount)
		discount.POST("/del", handle.DiscountDel)
	}

	return r
}
